#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution
{
public:
    string reverseStr(string s, int k)
    {
        int sLen = s.length();
        for (int i = 0; i < sLen; i += 2 * k)
        {
            int temp = i + k - 1;
            cout << i << " " << temp << endl;
            while (i < temp)
            {
                swap(s[i], s[temp]);
                i++;
                temp--;
            }
        }
        return s;
    }

    string reverseStr_2(string s, int k)
    {
        int n = s.length();
        for (int i = 0; i < n; i += 2 * k)
        {
            reverse(s.begin() + i, s.begin() + min(i + k, n));
        }
        return s;
    }
};
int main()
{
    Solution s;
    string str = "abcdefg";
    int k = 2;
    cout << s.reverseStr(str, k) << endl;
    return 0;
}
